package jpushdemo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.ViewGroup.LayoutParams;
import android.widget.TextView;
import android.widget.Toast;

import org.json.JSONException;
import org.json.JSONObject;

import cn.jpush.android.api.JPushInterface;

public class TestActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.d("TTT", "onCreate: =+++++++===");
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("用户自定义打开的Activity");
        Intent intent = getIntent();
        if (null != intent) {
	        Bundle bundle = getIntent().getExtras();
	        String title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
            Log.d("TTT", "onCreate: =+++++++===");
            System.out.println("ttttttttttttttttttttt");
            String content = bundle.getString(JPushInterface.EXTRA_ALERT);
	        tv.setText("Title : " + title + "  " + "Content : " + content);
            Log.d("TTT", "onCreate: ==================");
            System.out.println("33333333333355555555"+title);
            String json = bundle.getString(JPushInterface.EXTRA_EXTRA);
            if (json!=null) {
                try {
                    JSONObject jsonObject = new JSONObject(json);
                    String url = jsonObject.getString("url");
                    Log.d("TextA", "onCreate: " + url);
                    System.out.println("3333333333333333333333"+url);
                    Toast.makeText(TestActivity.this, ""+url, Toast.LENGTH_SHORT).show();
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        }
        addContentView(tv, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    }

}
